/**
 * 
 * ETH AI GAME LIBRARY
 * 
 * Author: Michael Jaworski
 * Copyright (c) Michael Jaworski 2010
 * http://code.google.com/p/eth/
 * 
 * Licence Agreement
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *	
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 */

package lib.eth.core.events
{
	import flash.events.Event;
	import lib.eth.core.errors.EthError;

	/**
	 * this is the only Eth event class that does not inherit from EthEvent. It
	 * carries the EthError class which holds any error information.
	 * 
	 * this event is only dispatched if a system is in an unusable state 
	 * because of it's own internal processes
	 * 
	 * @version 0.1
	 * 
	 */	
	public final class EthErrorEvent extends Event
	{
		/**
		 * the only event type constant for this class, because the error
		 * information is carried in the EthError class which is held in
		 * this event class.
		 */ 
		public static const ERROR:String = 'eth_error';
		
		/**
		 * the object that holds the particular information about the error
		 * in an Eth system
		 */ 
		private var _error:EthError;
		
		/**
		 * 
		 * this class must receive an error to be dispatched because the whole point
		 * is for it to report on an error that has caused an Eth system to be unusable
		 * 
		 * this event is only dispatched when the dispatching class/object needs to 
		 * be put out of use immediately
		 * 
		 * this event being fired is a sign of a critical failure only
		 * 
		 */ 
		public function EthErrorEvent (type:String, error:EthError, bubbles:Boolean = false)
		{
			super (type, bubbles, false);
			
			_error = error;
		}
		
		/**
		 * the error information specific to the Eth system which failed
		 */ 
		public function get error () : EthError
		{ return _error; }
		
		/**
		 * standard clone method
		 * 
		 * @see flash.events.Event
		 */ 
		override public function clone () : Event
		{
			return new EthErrorEvent (type, _error, bubbles);
		}		
	}
}